<?php

use yii\helpers\Html;
use yii\grid\GridView;

/* @var $this yii\web\View */
/* @var $searchModel common\models\MktFollowSearch */
/* @var $dataProvider yii\data\ActiveDataProvider */

$this->title = empty($model->nickname) ? 'Ta的关注' : "{$model->name}的关注";
$this->params['breadcrumbs'][] = ['label' => '粉丝', 'url' => ['fan/index']];
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="mkt-follow-index">

    <h1 style="display:none;"><?= Html::encode($this->title) ?></h1>
    <?php // echo $this->render('_search', ['model' => $searchModel]); ?>

    <p>
        <?php if (YII_DEBUG) echo Html::a('创建', ['create', 'user_id'=>$model->id], ['class' => 'btn btn-success ']) ?>
    </p>
    <?= GridView::widget([
        'dataProvider' => $dataProvider,
        //'filterModel' => $searchModel,
        'filterModel' => false,
        'columns' => [
            //['class' => 'yii\grid\SerialColumn'],

            //'id',
            //'user_id',
            //'follow_id',
			[
                'label' => '被关注者ID',
                'attribute' => 'follow_id'
            ],
            'followUser.name',
			[
				'label' => '头像',
				'format'=>'html',
				'value'=>function ($model, $key, $index, $column) { 
                    if (empty($model->followUser->headimgurl))
                        return '';
                    $headimgurl = Html::img(\common\wosotech\Util::getWxUserHeadimgurl($model->followUser->headimgurl, 46), ['style'=>'width:46px;']);
                    return $headimgurl;
				},
			],

			[
				'label'=>'微信昵称',
				'value'=>function ($model, $key, $index, $column) { 
					return empty($model->followUser->nickname) ? '' : $model->followUser->nickname;
				},
			],

            'create_time',

            ['class' => 'yii\grid\ActionColumn',
              'template' => '{delete}',  
            ],
        ],
    ]); ?>
</div>
